import requests
import json


headers = {
    "accept": "application/json, text/plain, */*",
    "accept-language": "zh-CN,zh;q=0.9",
    "content-type": "application/json",
    "origin": "https://ad.xiaohongshu.com",
    "priority": "u=1, i",
    "referer": "https://ad.xiaohongshu.com/aurora/ad/manage/unit?vSellerId=61381e3eda7b520001533a03",
    "sec-ch-ua": "\"Google Chrome\";v=\"135\", \"Not-A.Brand\";v=\"8\", \"Chromium\";v=\"135\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36",
    "v-seller-id": "61381e3eda7b520001533a03",
    "x-b3-traceid": "11b1beeb94e99f10"
}
cookies = {
    "a1": "1960e2acef4ev020adbqbgxdcps88phbukzabnajf50000272280",
    "webId": "4b6833e542f84e76fbfb34e006eddce8",
    "gid": "yjK8dJ0fS47WyjK8dJ0SdTI0i4dh8J80fDADuVikCfSUM028YYUxDD888JWJJY88jy8DJjDy",
    "customerClientId": "279177063808841",
    "abRequestId": "4b6833e542f84e76fbfb34e006eddce8",
    "web_session": "030037a0c46d4170a8a7797f8f204a4cdb8649",
    "x-user-id-pgy.xiaohongshu.com": "6426a4f7f95410000178a9cf",
    "webBuild": "4.62.3",
    "x-user-id-partner.xiaohongshu.com": "616fdd2b85d0b300016960dc",
    "access-token-ad.xiaohongshu.com": "customer.leona.AT-68c517506769382446338414svbshny4amaejak6",
    "loadts": "1747876626381",
    "xsecappid": "aurora-shell",
    "ares.beaker.session.id": "1747898171323092646914",
    "customer-sso-sid": "68c517507111794418882757vv13mjz3pmtozfij",
    "ads-partner-sid": "6897a531bb734f91982dc9b40d824b75",
    "system.alias": "ads_partner",
    "access-token-partner.xiaohongshu.com": "customer.ads_partner.AT-68c517507111798713850057zcf5archj08sx7ji",
    "websectiga": "cf46039d1971c7b9a650d87269f31ac8fe3bf71d61ebf9d9a0a87efb414b816c",
    "sec_poison_id": "2dbc846a-71fd-4356-abc6-ba77c30de61d",
    "acw_tc": "0a0d0f5817478945403697041e1660a0918ce1efb1ebad85d6a1a8f7106596"
}
url = "https://ad.xiaohongshu.com/api/leona/rtb/unit/search"
data = {
    "startTime": "2025-05-22",
    "endTime": "2025-05-22",
    "id": "",
    "pageNum": 1,
    "pageSize": 40
}
data = json.dumps(data, separators=(',', ':'))
response = requests.post(url, headers=headers, cookies=cookies, data=data)

print(response.text)
print(response)